package cn.ljy.authority.model;

import cn.ljy.common.model.BaseModel;
import cn.ljy.common.model.validate.UpdateWorkValidation;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.*;
import java.util.Date;

/**
 * 手机验证码实体类
 */
@ApiModel(value="手机验证码")
@Data
@EqualsAndHashCode(callSuper = false, of = {"id"})
@NoArgsConstructor
public class SysPhoneVerificationCode extends BaseModel {

    @NotNull(groups = UpdateWorkValidation.class,message="id不能为空")
    private Long id;//主键ID

    @NotBlank(message = "手机号不能为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
    private String phone;//手机号,与账户表的tel字段映射

    @NotBlank(message = "IP地址不能为空")
    @Size(max = 20, message = "IP地址长度不能超过20个字符")
    private String ip;//ip地址

    @NotBlank(message = "验证码不能为空")
    @Size(min = 4, max = 10, message = "验证码长度必须在4-10个字符之间")
    private String code;//验证码

    @NotNull(message = "验证码类型不能为空")
    @Min(value = 1, message = "验证码类型必须大于0")
    @Max(value = 3, message = "验证码类型必须小于等于3")
    private Integer type;//验证码类型(1:登录,2:注册,3:修改密码)

    private Boolean isUsed;//是否已使用(0:未使用,1:已使用)

//    @NotNull(message = "过期时间不能为空")
//    @Future(message = "过期时间必须是未来时间")
    private Date expireTime;//过期时间

    public interface SysPhoneVerificationCodeType {//用户状态
        int LOGIN = 1;//登录
        int REG = 2;//注册
        int UPDATEPASSWORD = 3;//修改密码
    }
}
